{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Determine Color of a Chessboard Square"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #math #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数学 #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: squareIsWhite"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #判断国际象棋棋盘中一个格子的颜色"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个坐标 <code>coordinates</code> ，它是一个字符串，表示国际象棋棋盘中一个格子的坐标。下图是国际象棋棋盘示意图。</p>\n",
    "\n",
    "<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/04/03/chessboard.png\" style=\"width: 400px; height: 396px;\" /></p>\n",
    "\n",
    "<p>如果所给格子的颜色是白色，请你返回 <code>true</code>，如果是黑色，请返回 <code>false</code> 。</p>\n",
    "\n",
    "<p>给定坐标一定代表国际象棋棋盘上一个存在的格子。坐标第一个字符是字母，第二个字符是数字。</p>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<b>输入：</b>coordinates = \"a1\"\n",
    "<b>输出：</b>false\n",
    "<b>解释：</b>如上图棋盘所示，\"a1\" 坐标的格子是黑色的，所以返回 false 。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<b>输入：</b>coordinates = \"h3\"\n",
    "<b>输出：</b>true\n",
    "<b>解释：</b>如上图棋盘所示，\"h3\" 坐标的格子是白色的，所以返回 true 。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<b>输入：</b>coordinates = \"c7\"\n",
    "<b>输出：</b>false\n",
    "</pre>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>coordinates.length == 2</code></li>\n",
    "\t<li><code>'a' <= coordinates[0] <= 'h'</code></li>\n",
    "\t<li><code>'1' <= coordinates[1] <= '8'</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [determine-color-of-a-chessboard-square](https://leetcode.cn/problems/determine-color-of-a-chessboard-square/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [determine-color-of-a-chessboard-square](https://leetcode.cn/problems/determine-color-of-a-chessboard-square/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['\"a1\"', '\"h3\"', '\"c7\"']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x=ord(coordinates[0])-ord('a')\n",
    "        y=ord(coordinates[1])-ord('1')\n",
    "        return (x + y) % 2 == 1\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        dic = {\n",
    "            \"a\":1,\n",
    "            \"b\":2,\n",
    "            \"c\":3,\n",
    "            \"d\":4,\n",
    "            \"e\":5,\n",
    "            \"f\":6,\n",
    "            \"g\":7,\n",
    "            \"h\":8\n",
    "        }\n",
    "\n",
    "        ind = dic[coordinates[0]] + int(coordinates[1])\n",
    "\n",
    "        if ind%2==0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        list_a=[]\n",
    "        for i in coordinates:\n",
    "            list_a.append(ord(i))\n",
    "        if list_a[0]%2:\n",
    "            if list_a[1]%2:\n",
    "                return False\n",
    "            else:\n",
    "                return True\n",
    "        else:\n",
    "            if list_a[1]%2:\n",
    "                return True\n",
    "            else:\n",
    "                return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x = ord(coordinates[0]) - ord(\"a\")\n",
    "        y = ord(coordinates[1]) - ord(\"1\")\n",
    "        q = x+y\n",
    "        w = q%2\n",
    "        if w == 0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (((ord(coordinates[0]) - ord('a') + 1) + int(coordinates[-1]))) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - ord('a') + 1 + int(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - ord('a') + 1 + int(coordinates[1])) % 2 == 1\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return coordinates[0] in \"bdfh\" if int(coordinates[1]) % 2 else coordinates[0] in \"aceg\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) + int(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0])+ord(coordinates[1]))%2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        ad={}\n",
    "        for i in range(97,97+8):            \n",
    "            for j in range(1,9):\n",
    "                idx=chr(i)+str(j)                \n",
    "                if (i%2==0 and j%2==0) or (i%2==1 and j%2==1):\n",
    "                    ad[idx]=False\n",
    "                else:\n",
    "                    ad[idx]=True\n",
    "        #r=[[k,v] for k,v in ad.items()]\n",
    "        #print(r)\n",
    "        return ad[coordinates]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x = ord(coordinates[0]) - ord('a')\n",
    "        y = ord(coordinates[1]) - ord('1')\n",
    "        return (x + y)%2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x = ord(coordinates[0]) - ord('a')\n",
    "        y = ord(coordinates[1])\n",
    "        if (x+y)%2 == 0:\n",
    "            return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "      return sum(map(ord,coordinates))&1==1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if (ord(coordinates[0])-int(coordinates[1])) % 2 == 0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return bool((ord(coordinates[0]) - 96 ^ int(coordinates[1])) & 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0])-int(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        # chars = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7}\n",
    "        if coordinates[0] in 'aceg':\n",
    "            return True if int(coordinates[1]) % 2 == 0 else False\n",
    "        else:\n",
    "            return True if int(coordinates[1]) % 2 != 0 else False\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x=ord(coordinates[0])-ord('a')\n",
    "        y=ord(coordinates[1])-ord('1')\n",
    "        return (x+y)%2==1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - 96 ^ int(coordinates[1])) & 1 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        s = ord(coordinates[0]) - ord('a') + int(coordinates[1]) - 1\n",
    "\n",
    "        return bool(s&1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if (int(ord(coordinates[0]))-int(coordinates[1]))%2 == 0 :\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x = ord(coordinates[0]) - ord('a')\n",
    "        y = ord(coordinates[1]) - ord('1')\n",
    "        return (x + y) % 2 == 1\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        a='0abcdefgh'\n",
    "        if int(coordinates[1])%2!=0:\n",
    "            if a.index(coordinates[0])%2!=0:return 1==2\n",
    "            else:return 1==1\n",
    "        if a.index(coordinates[0])%2!=0:return 1==1\n",
    "        else:return 1==2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if (int(ord(coordinates[0]))-int(coordinates[1]))%2 == 0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        col = ord(coordinates[0]) - 97\n",
    "        row = int(coordinates[1])\n",
    "        return (col+row)%2==0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) + int(coordinates[1])) % 2 == 1\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return int(ord(coordinates[0]))%2!=int(coordinates[1])%2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) + int(coordinates[1])) % 2 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - ord('a') + 1 + int(coordinates[1])) % 2 == 1\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - ord('a') + 1 + int(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - int(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) + ord(coordinates[1])) % 2 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        row = int(coordinates[1])\n",
    "        column = ord(coordinates[0]) - ord('a') + 1\n",
    "        return (row + column) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return ((ord(coordinates[0])-ord('a'))-int(coordinates[1]))%2==0\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) + ord(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord('h')-ord(coordinates[0]))%2!=int(coordinates[1])%2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str):\n",
    "        return (ord(coordinates[0]) - ord('a') + 1 + int(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - ord('a') + 1 + int(coordinates[1])) % 2 == 1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - ord('a') + ord(coordinates[1]) - ord('1')) % 2 ==1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0])%2 + int(coordinates[1]))%2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return \"abcdefgh\".index(coordinates[0]) % 2 != \"12345678\".index(coordinates[1]) % 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x1 = ['a', 'c', 'e', 'g']\n",
    "        x2 = ['b', 'd', 'f', 'h']\n",
    "        if coordinates[0] in x1:\n",
    "            if int(coordinates[1]) % 2 == 0:\n",
    "                return True\n",
    "        if coordinates[0] in x2:\n",
    "            if int(coordinates[1]) % 2 != 0:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x=ord(coordinates[0])\n",
    "        y=ord(coordinates[1])\n",
    "        return (x+y)%2==1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if ord(coordinates[0]) % 2 == ord(coordinates[1]) % 2:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0])-ord('a'))%2==int(coordinates[1])%2\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x = ord(coordinates[0]) - ord('a')\n",
    "        y = ord(coordinates[1]) - ord('1')\n",
    "        if (x + y) % 2 == 1:\n",
    "            return True\n",
    "        else:\n",
    "            return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0])-ord(\"a\")+1+int(coordinates[1]))%2==1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        num1, num2 = ord(coordinates[0]) - ord('a') + 1, ord(coordinates[1]) - ord('0')\n",
    "        return not (((num1 & 1) and (num2 & 1)) or (num1%2==0 and num2%2==0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x = ord(coordinates[0]) - ord('a')\n",
    "        y = ord(coordinates[1]) - ord('1')\n",
    "        return (x + y) % 2 == 1\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if (int(ord(coordinates[0]))-int(coordinates[1]))%2 == 0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        list1=list(coordinates)\n",
    "        list2=[\"a\",\"c\",'e','g']\n",
    "        list3=[\"1\",'3','5','7']\n",
    "        if list1[0] in list2:\n",
    "            if list1[1] in list3:\n",
    "                return False\n",
    "            else:\n",
    "                return True\n",
    "        else:\n",
    "            if list1[1] in list3:\n",
    "                return True\n",
    "            else:\n",
    "                return False "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        coordinates = list(coordinates)\n",
    "        coordinates[0] = ord(coordinates[0])-ord(\"a\")+1\n",
    "        coordinates[1] = int(coordinates[1])\n",
    "\n",
    "        if coordinates[0]%2:\n",
    "            # 奇数\n",
    "            if coordinates[1]%2:\n",
    "                return False\n",
    "            else:\n",
    "                return True\n",
    "        else:\n",
    "            if coordinates[1]%2:\n",
    "                return True\n",
    "            else:\n",
    "                return False\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        horizon={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}\n",
    "        if (horizon[coordinates[0]]+int(coordinates[1]))%2==0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        now=ord(coordinates[0])-ord(\"a\")+int(coordinates[1])\n",
    "        return now%2!=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        list_a=[]\n",
    "        for i in coordinates:\n",
    "            list_a.append(ord(i))\n",
    "        if list_a[0]%2:\n",
    "            if list_a[1]%2:\n",
    "                return False\n",
    "            else:\n",
    "                return True\n",
    "        else:\n",
    "            if list_a[1]%2:\n",
    "                return True\n",
    "            else:\n",
    "                return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return ((ord(coordinates[0])-ord('a'))+int(coordinates[1]))%2==0\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return not ((ord(coordinates[0]) - ord('a') & 1) + (int(coordinates[1]) & 1)) & 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        num1, num2 = ord(coordinates[0]) - ord('a') + 1, ord(coordinates[1]) - ord('0')\n",
    "        return (num1 + num2) % 2 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        a =ord(coordinates[0]) - ord('a') +1\n",
    "        return a%2!=int(coordinates[1])%2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        i = coordinates[0]\n",
    "        k = int(coordinates[1])\n",
    "        if i ==\"a\" or i == \"c\" or i ==\"e\" or i ==\"g\":\n",
    "            if k % 2 == 0:\n",
    "                return True\n",
    "            else:\n",
    "                return False\n",
    "        else:\n",
    "            if k % 2 == 0:\n",
    "                return False\n",
    "            else: \n",
    "                return True\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0]) - ord('a') + 1 + int(coordinates[1])) % 2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0])+int(coordinates[1]))%2==1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        lists = [0,0]\n",
    "        a = ord(coordinates[0]) - ord('a')\n",
    "        b = ord(coordinates[1]) - ord('1')\n",
    "        if(a + b) % 2 == 0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if coordinates[0] in ['a','c','e','g']:\n",
    "            if int(coordinates[1])%2==0:\n",
    "                return True\n",
    "            else:\n",
    "                return False\n",
    "        else:\n",
    "            if int(coordinates[1])%2==1:\n",
    "                return True\n",
    "            else:\n",
    "                return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        x, y = ord(coordinates[0]) - ord('a') + 1, int(coordinates[1])\n",
    "        print(x, y)\n",
    "        return (x % 2) ^ (y % 2) > 0          "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return ord(coordinates[0])+ord(coordinates[1]) & 1 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if coordinates[0] in ['a','c','e','g']:\n",
    "            if int(coordinates[1])%2!=0:\n",
    "                return False\n",
    "            else:\n",
    "                return True\n",
    "        else:\n",
    "            if int(coordinates[1])%2!=0:\n",
    "                return True\n",
    "            else:\n",
    "                return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        num1, num2 = ord(coordinates[0]) - ord('a') + 1, ord(coordinates[1]) - ord('0')\n",
    "        if ((num1 & 1) and (num2 & 1)) or (num1%2==0 and num2%2==0):\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        zd={'a':1,'b':0,'c':1,'d':0,'e':1,'f':0,'g':1,'h':0}\n",
    "        biao1=coordinates[0]\n",
    "        biao2=int(coordinates[1])\n",
    "        return (biao2+zd[biao1])%2!=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return (ord(coordinates[0])+ord(coordinates[1]))%2 == 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        return ((ord(coordinates[0]) - ord('a')) % 2 == 1)==(int(coordinates[1]) % 2 == 1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def squareIsWhite(self, coordinates: str) -> bool:\n",
    "        if ord(coordinates[0]) % 2 == 1 and int(coordinates[1]) % 2 == 1:\n",
    "            return False\n",
    "        elif ord(coordinates[0]) % 2 == 1 and int(coordinates[1]) % 2 == 0:\n",
    "            return True\n",
    "        elif ord(coordinates[0]) % 2 == 0 and int(coordinates[1]) % 2 == 0:\n",
    "            return False\n",
    "        return True"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
